<template>
  <div>
    <van-goods-action>
      <van-goods-action-icon :icon="isCollected?'star':'star-o'" :color="isCollected?'#ff5000':'#666'" :text="isCollected?'已收藏':'未收藏'" @click="clickColect" />
      <van-goods-action-icon icon="cart-o" text="购物车" :badge="goodsCount" @click="$router.push('/cart')" />
      <van-goods-action-button type="danger" text="立即购买" />
      <van-goods-action-button type="warning" text="加入购物车" @click="addToCart" />
    </van-goods-action>
  </div>
</template>

<script>
export default {
  props: ['goodsCount'],
  data () {
    return {
      isCollected: false
    }
  },
  methods: {
    addToCart() {
      // console.log('点击加入购物车');
      this.$emit('addToCart');
    },
    clickColect() {
      /* let token = localStorage.getItem('token');
      if (!token) {
        this.$toast('请先登录');
        setTimeout(()=>{
          this.$router.push('/user')
        }, 500)
      } */
      if (!this.utils.mustBeLogin())return;
      this.isCollected = !this.isCollected
    }
  }
}
</script>
 
<style lang = "less" scoped>
.van-goods-action {
  z-index: 9999;
}

</style>